home *** CD-ROM | disk | FTP | other *** search
/ Otherware / Otherware_1_SB_Development.iso / mac / util / comm / muucp43.sit / Mac_gnuucp / MailReader 4.3 / stack.txt < prev   
Encoding:
Text File  |  1991-01-28  |  17.1 KB  |  601 lines

  1. -- stack: in.3
  2. -- format: 8 (HyperCard 1)
  3. -- flags: 0x1000 (none)
  4. -- protect password hash: 0
  5. -- maximum user level: 5 (scripting)
  6. -- window: Rect(x1=0, y1=0, x2=0, y2=0)
  7. -- screen: Rect(x1=0, y1=0, x2=0, y2=0)
  8. -- card dimensions: w=0 h=0
  9. -- scroll: x=0 y=0
  10. -- background count: 1
  11. -- first background id: 4178
  12. -- card count: 7
  13. -- first card id: 3794
  14. -- list block id: 4821
  15. -- print block id: 3581
  16. -- font table block id: 0
  17. -- style table block id: 0
  18. -- free block count: 0
  19. -- free size: 0 bytes
  20. -- total size: 49024 bytes
  21. -- stack block size: 16896 bytes
  22. -- created by hypercard version: 0x01228000
  23. -- compacted by hypercard version: 0x01258000
  24. -- modified by hypercard version: 0x01258000
  25. -- opened by hypercard version: 0x01258000
  26. -- patterns[0]: 0x0000000000000000
  27. -- patterns[1]: 0x0000220000002200
  28. -- patterns[2]: 0x8800220088002200
  29. -- patterns[3]: 0xCC003300CC003300
  30. -- patterns[4]: 0xCC883300CC883322
  31. -- patterns[5]: 0xEE88BB22EE88BB22
  32. -- patterns[6]: 0xEECCBB33EECCBB33
  33. -- patterns[7]: 0xFFCCFF33FFCCFF33
  34. -- patterns[8]: 0xFFEEFFBBFFEEFFBB
  35. -- patterns[9]: 0xFFFFFFBBFFFFFFBB
  36. -- patterns[10]: 0x8010022001084004
  37. -- patterns[11]: 0xFFFFFFFFFFFFFFFF
  38. -- patterns[12]: 0x8822882288228822
  39. -- patterns[13]: 0x112244889126B02D
  40. -- patterns[14]: 0xA4907AFC0D0A4E4F
  41. -- patterns[15]: 0x2043415252494552
  42. -- patterns[16]: 0x0D0AAA00AA00AA00
  43. -- patterns[17]: 0x8822552288225522
  44. -- patterns[18]: 0x8855225588552255
  45. -- patterns[19]: 0x77DD77DD77DD77DD
  46. -- patterns[20]: 0x8000000000000000
  47. -- patterns[21]: 0xAA55AA55AA55AA55
  48. -- patterns[22]: 0x038448300C020101
  49. -- patterns[23]: 0x8244394482010101
  50. -- patterns[24]: 0x8814224188412214
  51. -- patterns[25]: 0x8080413E080814E3
  52. -- patterns[26]: 0x22048C7422179810
  53. -- patterns[27]: 0xBE808808EB088880
  54. -- patterns[28]: 0x25C8328964244C92
  55. -- patterns[29]: 0xA29C41BE2AC914EB
  56. -- patterns[30]: 0x40A00000040A0000
  57. -- patterns[31]: 0x8040200002040800
  58. -- patterns[32]: 0xAA00800088008000
  59. -- patterns[33]: 0xFF80808080808080
  60. -- patterns[34]: 0x081C22C180010204
  61. -- patterns[35]: 0xFF808080FF080808
  62. -- patterns[36]: 0xF87422478F172271
  63. -- patterns[37]: 0xBF00BFBFB0B0B0B0
  64. -- patterns[38]: 0xFF7FBE5DA2418000
  65. -- patterns[39]: 0xFAF5FAF5A050A050
  66. -- checksum: 0x0
  67. ----- HyperTalk script -----
  68. -- These XCMDs and XFCNs are included in this stack.
  69.  
  70. -- Files by Guy de Picciotto freeware
  71. -- CIS: 73300,3637
  72. -- GENIE: G.PICCIOTO
  73. --
  74. -- DoList Copyright ┬⌐1987 By James L. Paul
  75. -- Non-commercial use only!
  76. -- Compuserve 72767,3436
  77. -- GEnie J.Paul
  78. --
  79. -- fileName by Steve Maller
  80. -- Non-commercial use only!
  81.  
  82. on openStack
  83.   global ReadingMail
  84.   set userlevel to 5
  85.   if the version < "1.2" then
  86.     Answer "This stack requires Hypercard 1.2 or newer..." with "Drat!"
  87.     go home
  88.   end if
  89.   hide message box
  90.   show menubar
  91.   set the textfont of cd fld summary of cd 1 to Helvetica
  92.   set the textsize of cd fld summary of cd 1 to 12
  93.   put true into ReadingMail
  94.   getAlias
  95.   if line 1 of (cd fld TImeZone of cd Config) is empty then
  96.     get quote
  97.     repeat until number of chars of it is 3 or it is empty
  98.       Ask "Please enter your Time Zone..." with "EST"
  99.     end repeat
  100.     repeat with i=1 to 3
  101.       put chartonum(char i of it) into arg
  102.       if arg<123 and arg>96 then
  103.         put numtochar(arg-32) into char i of it
  104.       end if
  105.     end repeat
  106.     if it is not empty then put it into cd fld TimeZone of cd config
  107.   end if
  108. end openStack
  109.  
  110. on getAlias
  111.   global aliasLIst
  112.   put line 1 of (cd fld SpoolFolder of cd config) &":"&"Alias" into pref
  113.   put Files(pref,"TEXT") into temp
  114.   repeat with i=1 to number of lines of temp
  115.     put line i of temp into item i of aliasList
  116.   end repeat
  117. end getAlias
  118.  
  119. on makeSummary
  120.   set cursor to busy
  121.   set lockscreen to true
  122.   set lockmessages to true
  123.   go third cd
  124.   put 1 into i
  125.   put empty into cd fld summary of first cd
  126.   get (number of cds ) -7
  127.   repeat until short name of this cd Γëá "Mail"
  128.     put char 1 to 35 of line 1 of fld "From" && "--" && char 1 to 35 of line 1 of fld "Subject" into line i of cd fld Summary of first cd
  129.     add 1 to i
  130.     go next cd
  131.   end repeat
  132.   go first cd
  133.   put it into cd fld TotalMsgs of cd "GetNewMail"
  134.   redMsg
  135.   set lockmessages to false
  136.   set lockscreen to false
  137. end makeSummary
  138.  
  139. on RedMsg
  140.   put (number of cds ) -7 into j
  141.   put 3 into i
  142.   repeat until (short name of cd i) Γëá "Mail"
  143.     if hilite of btn red of cd i then subtract 1 from j
  144.     add 1 to i
  145.   end repeat
  146.   go first cd
  147.   put j into line 2 of cd fld TotalMsgs of cd "GetNewMail"
  148. end redMsg
  149.  
  150. on scrfld fname,arg
  151.   if number of lines of cd fld fname > arg then
  152.     set style of cd fld fname to scrolling
  153.   else
  154.     set style of cd fld fname to rectangle
  155.   end if
  156. end scrfld
  157.  
  158. function CheckNewMail
  159. global MailExists
  160. put makeMailFileName() into tmpname
  161. put "* " into mscan
  162. get (cd fld SpoolFolder of cd config) &":Mail:"
  163. if (cd fld MailScan of cd Config is not empty) then
  164.   repeat with i=1 to number of lines of cd fld MailScan of cd Config
  165.     put first word of line i of cd fld MailScan of cd Config into fn
  166.     if fileExists(it&fn) = 1 then
  167.       put fn & space after mscan
  168.     end if
  169.   end repeat
  170. end if
  171. put "*" after mscan
  172. if mscan is "* *" then put empty into mscan
  173. if fileExists(tmpname) = "1" or mscan is not empty then
  174.   put "You Have New Mail"&& mscan into cd fld "notes" of cd "GetNewMail"
  175.   if hilite of btn "Sound On" of cd "Config" then play mail
  176.   put 1 into MailExists
  177. else
  178.   put "No New Mail" into cd fld "notes" of cd "GetNewMail"
  179.   put 0 into MailExists
  180. end if
  181. end CheckNewMail
  182.  
  183. function makeMailFileName
  184. return (cd fld "SpoolFolder" of Cd "Config") & ":Mail:" & (Cd Fld "UserName" of Cd "Config")
  185. end makeMailFileName
  186.  
  187. function isNewMail
  188. global MailError
  189. put makeMailFileName() into MailFile
  190. put Mailfile & random(1000000) into NewMailName
  191. if fileExists (Mailfile) = "1" then
  192.   put fileRename (Mailfile, NewMailName) into MailError
  193.   return NewMailName
  194. else
  195.   return empty
  196. end if
  197. end isNewMail
  198.  
  199. function insertBody
  200. global to,from,subject,date,body
  201. if the length of body < cd fld Msgsize of cd config then
  202.   put body into cd fld "body"
  203. else
  204.   put StackDir() & ":Body." & the id of this cd into filename
  205.   put "Body of message too large for Hypercard," & return & "stored in: " & filename & "." into cd fld "body"
  206.   open file filename
  207.   write body to file filename
  208.   close file filename
  209. end if
  210. return 0
  211. end insertBody
  212.  
  213. function getTheNewMail
  214. global MailError
  215. put isNewMail() into NewMail
  216. put NewMail into cd fld Notes
  217. if NewMail is not empty then
  218.   put readNewMail(NewMail) into MailError
  219.   put fileDelete(NewMail) into MailError
  220. end if
  221. return 0
  222. end getTheNewMail
  223.  
  224. function readNewMail fileName
  225. global MailExists,MailCheckTime,to,from,replyto,subject,date,body
  226. global TotalMailMessages,ReadingMail
  227. put the id of cd "GetNewMail" into NewMailCard
  228. open file fileName
  229. repeat while ReadaMessage (fileName)
  230.   set LockScreen to true
  231.   set LockMessages to true
  232.   put false into ReadingMail
  233.   put the id of this cd into OldCardID
  234.   go cd MailMsgTemplate
  235.   domenu "Copy Card"
  236.   domenu "Paste Card"
  237.   set name of this cd to "Mail"
  238.   put the id of this cd into NewcardID
  239.   go cd "GetNewMail"
  240.   go NewCardID
  241.   put to into cd fld "to"
  242.   put from into fld "from"
  243.   put subject into fld "subject"
  244.   put date into cd fld "date"
  245.   put replyto into cd fld "ReplyTo"
  246.   put insertBody() into MailError
  247.   set cantDelete of NewcardID to false
  248.   set hilite of cd btn red to false
  249.   go cd "GetNewMail"
  250.   put true into ReadingMail
  251.   set lockmessages to false
  252.   set LockScreen to false
  253.   makeSummary
  254. end repeat
  255. close file fileName
  256. put 0 into MailExists
  257. put 0 into MailCheckTime
  258. return 0
  259. end ReadNewMail
  260.  
  261. function ReadaMessage name
  262. global from,to,replyto,date,subject,body,allDone
  263. put empty into from
  264. put empty into to
  265. put empty into date
  266. put empty into subject
  267. put empty into body
  268. put empty into replyto
  269. put false into Alldone
  270. put false into foundOne
  271. repeat while not allDone
  272.   Read from file name until return
  273.   set cursor to busy
  274.   if it is return or it is empty then
  275.     put true into allDone
  276.   else if word 1 of it is "From:" then
  277.     put doFrom (it) into MailError
  278.   else if word 1 of it is "Reply-To:" then
  279.     put doReplyTo (it) into MailError
  280.   else if word 1 of it is "To:" then
  281.     put doTo (it) into MailError
  282.   else if word 1 of it is "Date:" then
  283.     put doDate (it) into MailError
  284.   else if word 1 of it is "Subject:" then
  285.     put doSubject (it) into MailError
  286.   else
  287.     put it after body
  288.   end if
  289.   put it into cd fld notes of cd "GetNewMail"
  290. end repeat
  291. put return after body
  292. put false into allDone
  293. repeat while not allDone
  294.   read from file name until return
  295.   set cursor to busy
  296.   if it is empty then
  297.     put true into allDone
  298.   else if it contains numToChar(255) then
  299.     put true into alldone
  300.     put true into FoundOne
  301.   else
  302.     put it after body
  303.   end if
  304. end repeat
  305. if foundone is true then
  306.   put "Processed body of message" into cd fld notes of cd "GetNewMail"
  307. end if
  308. return foundone
  309. end ReadaMessage
  310.  
  311. -- Optimization by Ned Horvath
  312. -- ech@pegasus.att.com 1/27/90
  313. -- Cannot be used now besacuse of a bug in system 7.0
  314. -- Should be checked in release version of 7.0
  315. --function readNewMail fileName
  316. --  global MailExists,MailCheckTime,to,from,replyto,subject,date,body
  317. --  global TotalMailMessages,ReadingMail
  318. --  global MailData -- ECH
  319. --  put the id of cd "GetNewMail" into NewMailCard
  320. --  open file fileName
  321. -- ECH -- read...until fails -50 on HC2.0, Sys7.0b1
  322. -- ECH -- so we read all data into MailData for later reading
  323. -- ECH -- by ReadaMessage
  324. --  put "" into MailData
  325. --  repeat forever
  326. --    read from file fileName for 16384
  327. --    if it is empty then exit repeat
  328. --    put it after MailData
  329. --  end repeat
  330. --  close file fileName -- ECH this command was after the next repeat loop.
  331. -- ECH -- end of inserted code
  332. --  repeat while MailData is not empty
  333. --    if not ReadaMessage () then exit repeat
  334. --    set LockScreen to true
  335. --    set LockMessages to true
  336. --    put false into ReadingMail
  337. --    put the id of this cd into OldCardID
  338. --    go cd MailMsgTemplate
  339. --    domenu "Copy Card"
  340. --    domenu "Paste Card"
  341. --    set name of this cd to "Mail"
  342. --    put the id of this cd into NewcardID
  343. --    go cd "GetNewMail"
  344. --    go NewCardID
  345. --    put to into cd fld "to"
  346. --    put from into fld "from"
  347. --    put subject into fld "subject"
  348. --    put date into cd fld "date"
  349. --    put replyto into cd fld "ReplyTo"
  350. --    put insertBody() into MailError
  351. --    set cantDelete of NewcardID to false
  352. --    set hilite of cd btn red to false
  353. --    go cd "GetNewMail"
  354. --    put true into ReadingMail
  355. --    set lockmessages to false
  356. --    set LockScreen to false
  357. --    makeSummary
  358. --  end repeat
  359. -- ECH -- next statement moved to before loop
  360. -- ECH close file fileName
  361. --  put 0 into MailExists
  362. --  put 0 into MailCheckTime
  363. --  return 0
  364. --end ReadNewMail
  365.  
  366. --function ReadaMessage -- ECH name
  367. -- ECH name argument removed: data now in global MailData
  368. --  global from,to,replyto,date,subject,body,allDone
  369. --  global MailData -- ECH
  370. --  put empty into from
  371. --  put empty into to
  372. --  put empty into date
  373. --  put empty into subject
  374. --  put empty into body
  375. --  put empty into replyto
  376. --  put false into Alldone
  377. --  put false into foundOne
  378. --  repeat while not allDone
  379. -- ECH -- used to be: Read from file name until return
  380. --    put (line 1 of MailData) & return into it
  381. --    delete line 1 of MailData
  382. -- ECH
  383. --    set cursor to busy
  384. --    if it is return or it is empty then
  385. --      put true into allDone
  386. --    else if word 1 of it is "From:" then
  387. --      put doFrom (it) into MailError
  388. --    else if word 1 of it is "Reply-To:" then
  389. --      put doReplyTo (it) into MailError
  390. --    else if word 1 of it is "To:" then
  391. --      put doTo (it) into MailError
  392. --    else if word 1 of it is "Date:" then
  393. --      put doDate (it) into MailError
  394. --    else if word 1 of it is "Subject:" then
  395. --      put doSubject (it) into MailError
  396. --    else
  397. --      put it after body
  398. --    end if
  399. --    put it into cd fld notes of cd "GetNewMail"
  400. --  end repeat
  401. --  put return after body
  402. --  put false into allDone
  403. --  repeat while not allDone
  404. -- ECH -- Used to be: Read from file name until return
  405. --    put (line 1 of MailData) & return into it
  406. --    delete line 1 of MailData
  407. -- ECH
  408. --    set cursor to busy
  409. --    if it is empty then
  410. --      put true into allDone
  411. --    else if it contains numToChar(255) then
  412. --      put true into alldone
  413. --      put true into FoundOne
  414. --    else
  415. --      put it after body
  416. --    end if
  417. --  end repeat
  418. --  if foundone is true then
  419. --    put "Processed body of message" into cd fld notes --    of cd "GetNewMail"
  420. --  end if
  421. --  return foundone
  422. --end ReadaMessage
  423.  
  424. function doTo arg
  425. global to
  426. put arg into to
  427. end doTo
  428.  
  429. function doReplyTo arg
  430. global replyto
  431. put arg into replyto
  432. end doReplyTo
  433.  
  434. function doFrom arg
  435. global from
  436. put arg into from
  437. end doFrom
  438.  
  439. function doDate arg
  440. global date
  441. put arg into date
  442. end doDate
  443.  
  444. function doSubject arg
  445. global subject
  446. put arg into subject
  447. end doSubject
  448.  
  449. function stripBrackets arg
  450. put arg into tmp
  451. if char 1 of tmp is "<" then
  452.   delete char 1 of tmp
  453. end if
  454. if last char of tmp is ">" then
  455.   delete last char of tmp
  456. end if
  457. return tmp
  458. end stripBrackets
  459.  
  460. function stripBlanks arg
  461. put arg into tmp
  462. repeat while (char 1 of tmp is space or char 1 of tmp is return)
  463.   delete char 1 of tmp
  464. end repeat
  465. repeat while (last char of tmp is space or last char of tmp is return)
  466.   delete last char of tmp
  467. end repeat
  468. return tmp
  469. end stripBlanks
  470.  
  471. function StackDir
  472. put the long name of this stack into tmpName
  473. repeat while last character of tmpName <> ":"
  474.   delete last character of tmpName
  475. end repeat
  476. put 0 into i
  477. delete last character of tmpName
  478. repeat while i < 7
  479.   delete first character of tmpName
  480.   add 1 to i
  481. end repeat
  482. return tmpName
  483. end StackDir
  484.  
  485. function SendTo name
  486. -- a speedier version that writes everything to a variable
  487. -- then writes it all in one go to a file (also shorter)
  488. -- for comma, delimited names, the long stuff is only done once.
  489. global wrbody,multiple
  490. put (cd fld "SpoolFolder" of cd config) & ":Spool:" & "Tmp." & (cd fld "UserName" of cd config) into msgname
  491. put MakeTmpFileName(msgname) into msgname
  492. put "From " into myMail
  493. put (cd fld UserName of cd "Config") & " remote from " after myMail
  494. put (cd fld MachineName of cd "Config") after myMail
  495. put return after myMail
  496. put "To: " & stripblanks(cd fld "To") &return after myMail
  497. if cd fld "Cc" is not empty then put "Cc: " & stripblanks(cd fld "Cc") &return after myMail
  498. put "From: " & stripblanks(cd fld "From") &return after myMail
  499. put "Organization: " & stripblanks((cd fld "OrganizationName" of cd config)) & return after myMail
  500. put "Reply-To: " & stripblanks((cd fld "ReplyAddress" of cd config)) &return after myMail
  501. put "Date: " & stripblanks(cd fld "Date") & return after myMail
  502. put "Subject: " & stripblanks(cd fld "Subject") &return &return after myMail
  503. if not multiple or (multiple and wrbody is empty) then put WriteJustified(msgname,card field "Body",70) into wrbody
  504. put wrbody & return after myMail
  505. open file msgname
  506. write myMail to file msgname
  507. close file msgname
  508. put (cd fld "SpoolFolder" of cd config) & ":Spool:" & "Rmail." & (cd fld "UserName" of cd config) into temp
  509. put MakeTmpFileName(temp) into temp
  510. Open file temp
  511. write msgname &return &name &return to file temp
  512. Close file temp
  513. end Sendto
  514.  
  515. function copyFile fromFile, toFile
  516. put false into allDone
  517. repeat until allDone
  518.   Read from file fromFile until return
  519.   if it is empty then
  520.     put true into allDone
  521.   else write it to file toFile
  522. end repeat
  523. return 0
  524. end copyFile
  525.  
  526. function MakeTmpFileName firstPart
  527. repeat while true
  528.   put firstPart & random(100000) into tname
  529.   if fileExists(tname) is 0 then
  530.     return(tname)
  531.   end if
  532. end repeat
  533. end MakeTMpFileName
  534.  
  535. function WriteJustified fileName, String, width
  536. put empty into wrbody
  537. put String into tmpStr
  538. put return after tmpstr
  539. if hilite of btn "Add Line Wrap" of cd config then
  540.   repeat until (tmpStr is empty)
  541.     set cursor to busy
  542.     put false into writeReturn
  543.     put the number of chars of tmpStr into strLen
  544.     put offset(return, tmpStr) into lineLen
  545.     if (lineLen = 0) then put strLen into lineLen
  546.     if (lineLen >= width) then put width into lineLen
  547.     if (lineLen <= width) and (lineLen < strLen) then put true into writeReturn
  548.     if (lineLen > strLen) then put strLen into lineLen
  549.     repeat
  550.       if char lineLen of tmpStr is space or char lineLen of tmpStr is return or linelen=0 then
  551.         exit repeat
  552.       end if
  553.       subtract 1 from lineLen
  554.     end repeat
  555.     put char 1 to lineLen of tmpStr into currLine
  556.     delete char 1 to lineLen of tmpStr
  557.     if (last char of currline = return) then delete last char of currline
  558.     put currline after wrbody
  559.     if (writeReturn = true) then put return after wrbody
  560.   end repeat
  561. else
  562.   put tmpstr into wrbody
  563. end if
  564. return wrbody
  565. end WriteJustified
  566.  
  567. function GetAddressee address
  568. global begin, endd, ans
  569. put address into ans
  570. if word 1 of ans is "From:" then
  571.   delete word 1 of ans
  572. end if
  573. if word 1 of ans is "Reply-To:" then
  574.   delete word 1 of ans
  575. end if
  576. put offset("<", ans) into begin
  577. put offset(">", ans) into endd
  578. if ((begin Γëá 0) and (endd Γëá 0) and (endd > begin)) then
  579.   put char begin+1 to endd-1 of ans into ans
  580.   put stripBlanks(ans) into ans
  581.   return (ans)
  582. end if
  583. put offset("(", ans) into begin
  584. put offset(")", ans) into endd
  585. if ((begin Γëá 0) and (endd Γëá 0) and (endd > begin)) then
  586.   delete char begin to endd of ans
  587. end if
  588. put stripBlanks(ans) into ans
  589. return (ans)
  590. end GetAddressee
  591.  
  592. function outfilename
  593. put "Mail Output" into defaultName
  594. put StandardFile("put", defaultName) into SDFileout
  595. if SDFileout is empty then
  596.   return empty
  597. end if
  598. return(SDFileout)
  599. end outfilename
  600.  
  601.